package com.smartad.ApplicationServer;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.Socket;

public class SocketWorker extends Thread {
	private Socket _client;

	public SocketWorker(Socket ClientConn) {
		_client = ClientConn;
	}

	@Override
	public void run() {
		BufferedInputStream in = null;
		BufferedOutputStream out = null;
		try {
			in = new BufferedInputStream(_client.getInputStream());
			out = new BufferedOutputStream(_client.getOutputStream());

			byte[] buff = new byte[8192];
			int count = 0;
			
			while (true) {
				try {
					count = in.read(buff);

					//out.write(b);
				} catch (IOException e) {
					com.smartad.common.Log.i("Socket read failed");
					com.smartad.common.Log.i(e);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null)
					in.close();
				
				if (out != null)
					out.close();
				
				_client.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
